/**
* 描述：人才库
*/
<style lang="scss" scoped>
  @import 'src/styles/common';
  @import 'src/styles/company/index';
</style>
<template>
  <div class="content">
    <div class="com-main-title">
      <span class="tit">人才库</span>
      <div class="clear"></div>
    </div>
    <!--搜索条部分-->
    <div class="search-bar">
      <div class="oneImput fl wth160px">
        <el-input v-model="searchData.name" placeholder="名称" size="small"></el-input>
      </div>
      <div class="oneImput fr">
        <el-button type="primary" class="search-button fl" icon="search" @click="search" size="small">搜索</el-button>
        <div class="clear"></div>
      </div>
      <div class="clear"></div>
    </div>

    <!--工具条部分-->
    <div class="tool-bar"></div>

    <!--table部分-->
    <div class="table-content">
      <el-table
        size="mini"
        :data="list"
        v-loading="loading"
        :element-loading-text="loadingText"
        highlight-current-row
        border
        style="width: 100%">
        <el-table-column
          prop="screenName"
          label="账户名"
          align="center"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="name"
          label="真实姓名"
          align="center"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="major"
          label="主修专业"
          align="center"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="education"
          label="最高学历"
          align="center"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="phone"
          label="手机号"
          align="center"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="school"
          align="center"
          label="毕业院校"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="birth"
          align="center"
          show-overflow-tooltip
          label="生日">
        </el-table-column>
        <el-table-column label="操作" align="center" width="180px" fixed="right" :class="`xxx`" style="background-color: red">
          <template slot-scope="scope">
            <a class="cz" @click="queryDetail(scope.row.id)">查看简历</a>
            <a class="cz" @click="clickInvitation(scope.row.id)">邀请</a>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <hy-page v-show="pageShow"
               :current-page="searchData.page"
               :page-size="searchData.limit"
               :total-element="totalElement"
               @current-change="currentChange"></hy-page>
    </div>
    <Modal v-model="detailData.show" :mask-closable="false" style="min-width: 720px" class="jianLiDetail-modal">
      <p slot="header" style="color:#000;text-align:center;font-weight: bold;font-size: 18px;">
        <span>请选择职位</span>
      </p>
      <div style="transform: translateX(0%) translateZ(0px);" v-if="detailData.show">
        <!--<Form ref="detailData.baseForm" :model="detailData.baseForm" :label-width="100" class="main-add-1 formNoRadius02">-->
          <!--<FormItem label="职位：" prop="sex" :required="true">-->
            <!--<Select v-model="detailData.baseForm.jobId" placeholder="职位：">-->
              <!--<template>-->
                <!--<i-option v-for="item in detailData.jobList" :value="item.id" :key="item.id">{{item.title}}</i-option>-->
              <!--</template>-->
            <!--</Select>-->
          <!--</FormItem>-->
        <!--</Form>-->
        <el-form ref="detailData.baseForm" :model="detailData.baseForm" label-width="80px">
          <el-form-item label="职位:">
            <el-select v-model="detailData.baseForm.jobId" placeholder="职位:" style="width: 100%">
              <el-option v-for="item in detailData.jobList" :value="item.id" :key="item.id" :label="item.title"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" style="width:220px;margin:0 auto;">
        <i-button type="primary" size="large" @loading="detailData.addLoading" @click="invite" style="width:100px;">确定</i-button>
        <i-button size="large" @click="detailData.show = false" style="width:100px;">取消</i-button>
      </div>
    </Modal>
  </div>
</template>
<script>
  import list from '@/js/mixins/list';
  import { queryList, queryCount, jobList } from '@/service/company/talentPool/talentPoolMService';
  import { invite } from '@/service/company/jobInvitation/jobInvitationMService';
  import JobClassify from '@/components/common/jobClassify/jobClassify';
  export default {
    mixins: [list],
    components: {
      JobClassify
    },
    data () {
      return {
        loading: true,
        searchData: {},
        detailData: {
          show: false,
          talentId: null,
          baseForm: {},
          jobList: [],
          addLoading: false
        }
      };
    },
    mounted () {
      this.getJobList(); // 获取职务列表
    },
    methods: {
      async _getList () {
        this.loading = true;
        let result = await queryList(this.searchData);
        let temp = await queryCount(this.searchData);
        if (!result.data.length) result.data = null;
        this.list = result.data || [];
        this.totalElement = temp.data || 0;
        this.loading = false;
      },
      // 点击查看简历
      async queryDetail (id) {
        this.$router.push({path: '/company/main/talentPool/detail', query: {id: id}});
      },
      // 点击邀请
      clickInvitation (id) {
        this.$confirm(`确定邀请？`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          this.detailData.talentId = id;
          this.detailData.show = true;
        }).catch(() => {
        });
      },
      async invite () {
        if (!this.detailData.baseForm.jobId) {
          this.$Notice.warning({title: `请选择职位！`});
          return;
        }
        let params = {jobId: this.detailData.baseForm.jobId, talentId: this.detailData.talentId};
        await invite(params);
        this.$Notice.success({title: `已邀请`});
        this.detailData.show = false;
        this.currentChange();
      },
      // 获取职业列表
      async getJobList () {
        let param = {pageNo: 1, pageSize: 1000};
        let result = await jobList(param);
        this.detailData.jobList = result.data;
      }
    }
  };
</script>
